package com.example.bilibili.util;

import org.jetbrains.annotations.TestOnly;
import org.junit.Test;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5 {
    public static String EncoderPwdByMD5(String str) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        byte[] a=md5.digest(str.getBytes());
        String codestr=new BigInteger(1,a ).toString(16);
        return codestr;
    }
  @Test
    public  static  void main(String[] args) throws NoSuchAlgorithmException {
        MD5 md5=new MD5();
        System.out.println(md5.EncoderPwdByMD5("123321"));//张三123的密码
    }
}
